<!DOCTYPE html>
<!-- saved from url=(0080)http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi -->
<html itemscope="" itemtype="http://schema.org/QAPage"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <title>php - I never really understood: what is CGI? - Stack Overflow</title>
    <link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=038622610830">
    <link rel="apple-touch-icon image_src" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png?v=fd7230a85918">
    <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="http://stackoverflow.com/opensearch.xml">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:domain" content="stackoverflow.com">
    <meta property="og:type" content="website">
    <meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=fde65a5a78c6">
    <meta name="twitter:title" property="og:title" itemprop="title name" content="I never really understood: what is CGI?">
    <meta name="twitter:description" property="og:description" itemprop="description" content="CGI is a Comman Gateway Interface. As the name says, it is a &quot;common&quot; gateway interface for everything. It is so trivial and naive from the name. I feel that I understood this and I felt this every...">
    <meta property="og:url" content="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi">
    <link rel="canonical" href="./php - I never really understood  what is CGI  - Stack Overflow_files/php - I never really understood  what is CGI  - Stack Overflow.html">

    
    
    <script type="text/javascript" async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/ados"></script><script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/quant.js"></script><script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/beacon.js"></script><script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/analytics.js"></script><script type="text/javascript" async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/ados.js"></script><script src="./php - I never really understood  what is CGI  - Stack Overflow_files/jquery.min.js"></script>
    <script src="./php - I never really understood  what is CGI  - Stack Overflow_files/stub.en.js"></script>
    <link rel="stylesheet" type="text/css" href="./php - I never really understood  what is CGI  - Stack Overflow_files/all.css">
    
    <link rel="alternate" type="application/atom+xml" title="Feed for question &#39;I never really understood: what is CGI?&#39;" href="http://stackoverflow.com/feeds/question/2089271">
    <script>
        
        StackExchange.ready(function () {
                
                StackExchange.using("snippets", function () {
                    StackExchange.snippets.initSnippetRenderer();
                });
                

            StackExchange.using("postValidation", function () {
                StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
            });

            
            StackExchange.question.init({showAnswerHelp:true,totalCommentCount:4,shownCommentCount:4,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:2089271});

            styleCode();

                StackExchange.realtime.subscribeToQuestion('1', '2089271');
            
                    });
    </script>


    <script>
        StackExchange.init({"locale":"en","stackAuthUrl":"https://stackauth.com","serverTime":1416380880,"networkMetaHostname":"meta.stackexchange.com","routeName":"Questions/Show","styleCode":true,"enableUserHovercards":true,"snippets":{"enabled":true,"domain":"stacksnippets.net"},"site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"nonAsciiTags":true,"enableSocialMediaInSharePopup":true},"user":{"fkey":"796045aaa394c7982362adb5b4d35e40","isAnonymous":true,"ab":{"tutorial_tooltips":{"v":"b","g":2}}}});
        StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"23ba629efd25","js/moderator.en.js":"3bf88d4bfb80","js/full-anon.en.js":"48b2588cbef3","js/full.en.js":"de75b9380252","js/wmd.en.js":"ea73b10815e2","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"16b738e40bb4","js/help.en.js":"7f73fe585f5f","js/tageditor.en.js":"55273fa7648e","js/tageditornew.en.js":"589297fedab1","js/inline-tag-editing.en.js":"7e793ad8611c","js/revisions.en.js":"b9f74067e1f5","js/review.en.js":"1f57175f3011","js/tagsuggestions.en.js":"7dfec0d2a2d7","js/post-validation.en.js":"94863d4e88c0","js/explore-qlist.en.js":"4e6f969d97ee","js/events.en.js":"d3998dda718c","js/keyboard-shortcuts.en.js":"b181da62c03e","js/external-editor.en.js":"0cab63d6a599","js/external-editor.en.js":"0cab63d6a599","js/snippet-javascript.en.js":"9d776fe161e5","js/snippet-javascript-codemirror.en.js":"98d29d23e631"});
        StackExchange.using("gps", function() {
             StackExchange.gps.init(true);
        });
    </script>
    
        <script>
            StackExchange.ready(function () {
                $('#nav-tour').click(function () {
                    StackExchange.using("gps", function() {
                        StackExchange.gps.track("aboutpage.click", { aboutclick_location: "headermain" }, true);
                    });
                });
            });
        </script>
    
    
<script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/full-anon.en.js"></script><script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/snippet-javascript.en.js"></script><script async="" src="./php - I never really understood  what is CGI  - Stack Overflow_files/post-validation.en.js"></script><script type="text/javascript" src="./php - I never really understood  what is CGI  - Stack Overflow_files/adFeedback.js"></script><link rel="stylesheet" href="http://static.adzerk.net/Extensions/adFeedback.css"><link href="./php - I never really understood  what is CGI  - Stack Overflow_files/sidebar.min.css" type="text/css" rel="stylesheet"></head>
<body class="question-page new-topbar">
    <noscript>&lt;div id="noscript-padding"&gt;&lt;/div&gt;</noscript>
    <div id="notify-container"></div>
    <div id="overlay-header"></div>
    <div id="custom-header"></div>




<div class="topbar">
    <div class="topbar-wrapper">

        <div class="js-topbar-dialog-corral">

<div class="topbar-dialog siteSwitcher-dialog dno">
    <div class="header">
        <h3><a href="http://stackoverflow.com/">current community</a></h3>
    </div>
    <div class="modal-content current-site-container">
        <ul class="current-site">
                <li>
                        <div class="related-links">
            <a href="http://chat.stackoverflow.com/" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a>
                    <a href="http://blog.stackoverflow.com/" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:7 })">blog</a>
            </div>




    <a href="http://stackoverflow.com/" class="current-site-link site-link js-gps-track" data-id="1" data-gps-track="
        site_switcher.click({ item_type:3 })">
        <div class="site-icon favicon favicon-stackoverflow" title="Stack Overflow"></div>
        Stack Overflow
    </a>

                </li>
                <li class="related-site">
                        <div class="L-shaped-icon-container">
        <span class="L-shaped-icon"></span>
    </div>

                    



    <a href="http://meta.stackoverflow.com/" class="site-link js-gps-track" data-id="552" data-gps-track="
            site.switch({ target_site:552, item_type:3 }),
        site_switcher.click({ item_type:4 })">
        <div class="site-icon favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>
        Meta Stack Overflow
    </a>

                </li>
                            <li class="related-site">
                        <div class="L-shaped-icon-container">
        <span class="L-shaped-icon"></span>
    </div>

                    <a class="site-link js-gps-track" href="http://careers.stackoverflow.com/?utm_source=stackoverflow.com&utm_medium=site-ui&utm_campaign=multicollider" data-gps-track="site_switcher.click({ item_type:9 })">
                        <div class="site-icon favicon favicon-careers" title="Stack Overflow Careers"></div>
                        Stack Overflow Careers
                    </a>
                </li>
        </ul>
    </div>
    
    <div class="header" id="your-communities-header">
        <h3>
your communities        </h3>
            
    </div>
    <div class="modal-content" id="your-communities-section">
            
            <div class="call-to-login">
                        <a href="https://stackoverflow.com/users/signup?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2089271%2fi-never-really-understood-what-is-cgi" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a>
                    or
                    <a href="https://stackoverflow.com/users/login?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2089271%2fi-never-really-understood-what-is-cgi" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a>

                    to customize your list.
            </div>
    </div>
    
    <div class="header">
        <h3><a href="http://stackexchange.com/sites">more stack exchange communities</a></h3>
    </div>
    <div class="modal-content">
            <div class="child-content"></div>
    </div>
</div>
        </div>

        <div class="network-items">

            <a href="http://stackexchange.com/" class="topbar-icon icon-site-switcher yes-hover js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 131 Stack Exchange sites">
                <span class="hidden-text">Stack Exchange</span>
            </a>

        </div>

        <div class="topbar-links">

                <div class="links-container">
                    <span class="topbar-menu-links">
                            <a href="https://stackoverflow.com/users/signup?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2089271%2fi-never-really-understood-what-is-cgi" class="login-link">sign up</a>
                            <a href="https://stackoverflow.com/users/login?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2089271%2fi-never-really-understood-what-is-cgi" class="login-link">log in</a>
                            <a href="http://stackoverflow.com/tour">tour</a>

                            <a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" class="icon-help js-help-button" title="Help Center and other resources">
        help
        <span class="triangle"></span>
    </a>
    <div class="topbar-dialog help-dialog js-help-dialog dno">
        <div class="modal-content">
            <ul>
                                    <li>
                        <a href="http://stackoverflow.com/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">
                            Tour
                            <span class="item-summary">
                                Start here for a quick overview of the site
                            </span>
                        </a>
                    </li>
                <li>
                    <a href="http://stackoverflow.com/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">
                        Help Center
                        <span class="item-summary">
                            Detailed answers to any questions you might have
                        </span>
                    </a>
                </li>
                    <li>
                        <a href="http://meta.stackoverflow.com/" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">
                            Meta
                            <span class="item-summary">
                                Discuss the workings and policies of this site
                            </span>
                        </a>
                    </li>
            </ul>
        </div>
    </div>

                            <a href="http://careers.stackoverflow.com/?utm_source=stackoverflow.com&utm_medium=site-ui&utm_campaign=anon-topbar">stack overflow careers</a>
                    </span>
                </div>

            <div class="search-container">
                <form id="search" action="http://stackoverflow.com/search" method="get" autocomplete="off">
                    <input name="q" type="text" placeholder="search" value="" tabindex="1" autocomplete="off" maxlength="240">
                </form>
            </div>

        </div>
    </div>
</div>
    <script>
        StackExchange.ready(function() { StackExchange.topbar.init(); });
    </script>

    <div class="container">
        <div id="header">
            <br class="cbt">
            <div id="hlogo">
                <a href="http://stackoverflow.com/">
                    Stack Overflow
                </a>
            </div>
            <div id="hmenus">
                <div class="nav mainnavs">
                    <ul>
                        <li class="youarehere"><a id="nav-questions" href="http://stackoverflow.com/questions">Questions</a></li>
                        <li><a id="nav-tags" href="http://stackoverflow.com/tags">Tags</a></li>
                        <li><a id="nav-users" href="http://stackoverflow.com/users">Users</a></li>
                        <li><a id="nav-badges" href="http://stackoverflow.com/help/badges">Badges</a></li>
                        <li><a id="nav-unanswered" href="http://stackoverflow.com/unanswered">Unanswered</a></li>
                    </ul>
                </div>
                <div class="nav askquestion">
                    <ul>
                        <li>
                            <a id="nav-askquestion" href="http://stackoverflow.com/questions/ask">Ask Question</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        



        <div id="content" class="snippet-hidden">
            

<div itemscope="" itemtype="http://schema.org/Question">
	<link itemprop="image" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
			<!--googleoff: all-->

<div id="herobox-mini">
    <div id="hero-content">
        <span id="controls">
            <a href="http://stackoverflow.com/tour" id="tell-me-more" class="button">Take the 2-minute tour</a>
            <span id="close"><a title="click to dismiss">×</a></span>
        </span>
        <div id="blurb">
            Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
        </div>        
    </div>
    <script>
        $('#tell-me-more').click(function () {
            var clickSource = $("body").attr("class") + '-mini';
            if ($("body").hasClass("questions-page")) {
                clickSource = 'questionpagemini';
            } else if ($("body").hasClass("question-page")) {
                clickSource = 'questionpagemini';
            } else if ($("body").hasClass("home-page")) {
                clickSource = 'homepagemini';
            }

            StackExchange.using("gps", function () {
                StackExchange.gps.track("aboutpage.click", { aboutclick_location: clickSource } , true);
            });
        });
        $('#herobox-mini #close').click(function () {
            StackExchange.using("gps", function () {
                StackExchange.gps.track("hero.action", { hero_action_type: "close" }, true);
            });
            $.cookie("hero", "none", { path: "/", expires: 365 });
            var $hero = $("#herobox-mini");
            $hero.slideUp('fast', function () { $hero.remove(); });
            return false;
        });
    </script>
</div>
			<!--googleon: all-->
			<div id="question-header">
			<h1 itemprop="name"><a href="./php - I never really understood  what is CGI  - Stack Overflow_files/php - I never really understood  what is CGI  - Stack Overflow.html" class="question-hyperlink">I never really understood: what is CGI?</a></h1>
		</div>
			<div id="mainbar">

			

<div class="question" data-questionid="2089271" id="question">

    <script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk1873211749",4).setZone(43) ; });                    
            </script>
            <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1873211749">
            <iframe id="ados_frame_adzerk1873211749_403202" frameborder="0" scrolling="no" height="90" width="728"></iframe><img height="0px" width="0px" border="0" style="position:absolute;" src="./php - I never really understood  what is CGI  - Stack Overflow_files/i.gif"><div class="adzerk-vote-controls" style="display:none;"><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li><label><input type="radio" value="12" name="downvoteReason">Uninteresting</label></li><li><label><input type="radio" value="13" name="downvoteReason">Misleading</label></li><li><label><input type="radio" value="14" name="downvoteReason">Offensive</label></li><li><label><input type="radio" value="15" name="downvoteReason">Repetitive</label></li></ul><a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" class="adzerk-vote-cancel">Oops! I didn't mean to do this.</a></form></div></div>    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089271">
    <a class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">329</span>
    <a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>
    
    <a class="star-off" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" title="This is a favorite question (click again to undo)">favorite</a>
    <div class="favoritecount"><b>151</b></div>   

</div>

            </td>
            
<td class="postcell">
<div>
    <div class="post-text" itemprop="text">

        <p>CGI is a Comman Gateway Interface. As the name says, it is a "common" gateway interface for everything. It is so trivial and naive from the name. I feel that I understood this and I felt this every time I encountered this word. But frankly, I didn't. I'm still confused. </p>

<p>I am a PHP programmer. I did lot of web development. </p>

<blockquote>
  <p>user (client) request for page ---&gt; webserver(-&gt;embedded PHP
  interpreter) ----&gt; Server side(PHP) Script ---&gt; MySQL Server.</p>
</blockquote>

<p>Now say my PHP Script can fetch results from MySQL Server &amp;&amp; MATLAB Server &amp;&amp; Some other server.</p>

<p>So, now PHP Script is the CGI? because its interface for the between webserver &amp; All other servers? I don't know. Sometimes they call CGI, a technology &amp; othertimes they call CGI a program or someother server. </p>

<ul>
<li><p>What exactly is CGI?</p></li>
<li><p>Whats the big deal with <code>/cgi-bin/*.cgi</code>? Whats up with this? I don't know what is this <code>cgi-bin</code> directory on the server for. I don't know why they have *.cgi extensions.</p></li>
<li><p>Why does Perl always comes in the way. CGI &amp; Perl (language). I also don't know whats up with these two. Almost all the time I keep hearing these two in combination "CGI &amp; Perl". This book is another great example <a href="http://rads.stackoverflow.com/amzn/click/1565924193">CGI Programming with Perl</a> Why not "CGI Programming with PHP/JSP/ASP". I never saw such things. </p></li>
<li><p><strong>CGI Programming in C</strong> this confuses me a lot. in <strong>C??</strong> Seriously?? I don't know what to say. I"m just confused. "in C"?? This changes everything. Program needs to be compiled and executed. This entirely changes my view of web programming. When do I compile? How does the program gets executed (because it will be a machine code, so it must execute as a independent process). How does it communicate with the web server? IPC? and interfacing with all the servers (in my example MATLAB &amp; MySQL) using socket programming? I'm lost!!</p></li>
<li><p>They say that CGI is depreciated. Its no more in use. Is it so? What is its latest update? </p></li>
</ul>

<blockquote>
  <p>Once, I ran into a situation where I
  had to give HTTP PUT request access to
  web server (Apache HTTPD). Its a long
  back. So, as far as I remember this is
  what I did:</p>
  
  <ol>
  <li><p>Edited the configuration file of Apache HTTPD to tell webserver to pass
  all HTTP PUT requests to some
  <code>put.php</code> ( I had to write this PHP
  script)</p></li>
  <li><p>Implement put.php to handle the request (save the file to the location
  mentioned)</p></li>
  </ol>
  
  <p>People said that I wrote a CGI Script.
  Seriously, I didn't have clue what
  they were talking about.</p>
</blockquote>

<ul>
<li>Did I really write CGI Script?  </li>
</ul>

<p>I hope you understood what my confusion is. (Because I myself don't know where I'm confused). I request you guys to keep your answer as simple as possible. I really can't understand any fancy technical terminology. At least not in this case. </p>

<p><strong>EDIT:</strong></p>

<p>I found this amazing tutorial <a href="http://www.whizkidtech.redprince.net/cgi-bin/tutorial">"CGI Programming Is Simple!" - CGI Tutorial</a> Which explains the concepts in <strong>simplest</strong> possible way. After reading this article you may want to read <a href="http://www.cs.tut.fi/~jkorpela/forms/cgic.html">Getting Started with CGI Programming in C</a> to supplement your understanding with actual code samples. I've also added these links to this tutorial to Wikipedia's article : <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface">http://en.wikipedia.org/wiki/Common_Gateway_Interface</a></p>

    </div>
    <div class="post-taglist">
        <a href="http://stackoverflow.com/questions/tagged/php" class="post-tag js-gps-track" title="show questions tagged &#39;php&#39;" rel="tag">php</a> <a href="http://stackoverflow.com/questions/tagged/asp.net" class="post-tag js-gps-track" title="show questions tagged &#39;asp.net&#39;" rel="tag">asp.net</a> <a href="http://stackoverflow.com/questions/tagged/jsp" class="post-tag js-gps-track" title="show questions tagged &#39;jsp&#39;" rel="tag">jsp</a> <a href="http://stackoverflow.com/questions/tagged/cgi" class="post-tag js-gps-track" title="show questions tagged &#39;cgi&#39;" rel="tag">cgi</a> 
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/q/2089271" title="short permalink to this question" class="short-link" id="link-post-2089271">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089271/edit" class="suggest-edit-post" title="">improve this question</a></div>        
    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089271/revisions" title="show all edits to this post">edited <span title="2014-04-11 15:01:13Z" class="relativetime">Apr 11 at 15:01</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <br>
        
    </div>
</div>    </td>
    <td class="post-signature owner">
        <div class="user-info ">
    <div class="user-action-time">
        asked <span title="2010-01-18 21:15:48Z" class="relativetime">Jan 18 '10 at 21:15</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/193653/claws"><div><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/a863c2bf5491d989180b8d7e982424b3" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/193653/claws">claws</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">9,308</span><span title="21 gold badges"><span class="badge1"></span><span class="badgecount">21</span></span><span title="82 silver badges"><span class="badge2"></span><span class="badgecount">82</span></span><span title="146 bronze badges"><span class="badge3"></span><span class="badgecount">146</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</div>
</td>
        </tr>
                
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089271" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-2021704" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">I've already seen CGI writen in Cobol. No kiding!</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/14673/luc-m" title="5414 reputation" class="comment-user">Luc M</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021704_2089271"><span title="2010-01-18 21:25:25Z" class="relativetime-clean">Jan 18 '10 at 21:25</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021768" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Luc M. Interested. Which CGI do you mean (given that there exists a raycaster in LINQ...)?</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/148423/joe" title="18858 reputation" class="comment-user">Joe</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021768_2089271"><span title="2010-01-18 21:33:37Z" class="relativetime-clean">Jan 18 '10 at 21:33</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021998" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">4</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@claws: People, mainly old-school, will call ANY code,  regardless of the actual method of execution,  executed via the webserver a CGI.   What you actually wrote is a PHP script, which may  or may not be executed via the CGI protocol.   Your confusion seems to stem from the ambivalent  meaning of CGI, a protocol to execute code and the  code that's being executed via the protocol  (which later on got generalized to mean  any web-executed code)</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/5190/vinko-vrsalovic" title="122948 reputation" class="comment-user">Vinko Vrsalovic</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021998_2089271"><span title="2010-01-18 21:59:26Z" class="relativetime-clean">Jan 18 '10 at 21:59</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2523901" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">4</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">I guess, Now its time for me to take this to a next level. "CGI programming in assembly language" :D</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/193653/claws" title="9308 reputation" class="comment-user owner">claws</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2523901_2089271"><span title="2010-03-26 18:45:29Z" class="relativetime-clean">Mar 26 '10 at 18:45</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089271" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>        </tbody></table>
</div>

			<div id="answers">

				<a name="tab-top"></a>
				<div id="answers-header">
					<div class="subheader answers-subheader">
						<h2>
								11 Answers
                                <span style="display:none;" itemprop="answerCount">11</span>
						</h2>
						<div>
							<div id="tabs">
        <a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi?answertab=active#tab-top" title="Answers with the latest activity first">active</a>
        <a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi?answertab=oldest#tab-top" title="Answers in the order they were provided">oldest</a>
        <a class="youarehere" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi?answertab=votes#tab-top" title="Answers with the highest score first">votes</a>
</div>
						</div>
					</div>    
				</div>    




  
<a name="2089297"></a>
<div id="answer-2089297" class="answer accepted-answer" data-answerid="2089297" itemscope="" itemtype="http://schema.org/Answer" itemprop="acceptedAnswer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089297">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">182</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


        <span class="vote-accepted-on load-accepted-answer-date" title="loading when this answer was accepted...">accepted</span>
</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>CGI is an interface which tells the webserver how to pass data back and forth to and from an application.  More specifically, it describes how request information is passed in environment variables (such as request type, remote IP address), how the reqeust body is passed in via standard input, and how the response is passed out via standard output. You can refer to the <a href="http://hoohoo.ncsa.illinois.edu/cgi">CGI specification</a> for details.</p>

<p>To use your image:</p>

<p><code>user (client) request for page ---&gt; webserver ---[CGI]----&gt; Server side Program ---&gt; MySQL Server.</code></p>

<p>Most, if not all, webservers can be configured to execute a program as a 'CGI'. This means that the webserver, upon receiving a request, will forward the data to a specific program, setting some environment variables and marshalling the parameters via standard input and standard output so the program can know where and what to look for.</p>

<p>The main benefit is that you can run ANY executable code from the web, given that both the webserver and the program know how CGI works. That's why you could write web programs in C or Bash with a regular CGI-enabled webserver. That, and that most programming environments can easily use standard input, standard output and environment variables.</p>

<p>In your case you most likely used another, specific for PHP, means of communication between your scripts and the webserver, this, as you well mention in your question, is an embedded interpreter called mod_php.</p>

<p>So, answering your questions:</p>

<blockquote>
  <p>What exactly is CGI?</p>
</blockquote>

<p>See above.</p>

<blockquote>
  <p>Whats the big deal with /cgi-bin/*.cgi? Whats up with this? I don't know what is this cgi-bin directory on the server for. I don't know why they have *.cgi extensions.</p>
</blockquote>

<p>That's the traditional place for cgi programs, many webservers come with this directory pre configured to execute all binaries there as CGI programs. The .cgi extension denotes an executable that is expected to work through the CGI.</p>

<blockquote>
  <p>Why does Perl always comes in the way. CGI &amp; Perl (language). I also don't know whats up with these two. Almost all the time I keep hearing these two in combination "CGI &amp; Perl". This book is another great example CGI Programming with Perl Why not "CGI Programming with PHP/JSP/ASP". I never saw such things.</p>
</blockquote>

<p>Because Perl is ancient (older than PHP, JSP and ASP which all came to being when CGI was already old, Perl existed when CGI was new) and became fairly famous for being a very good language to serve dynamic webpages via the CGI. Nowadays there are other alternatives to run Perl in a webserver, mainly <a href="http://perl.apache.org/">mod_perl</a>.</p>

<blockquote>
  <p>CGI Programming in C this confuses me a lot. in C?? Seriously?? I don't know what to say. I"m just confused. "in C"?? This changes everything. Program needs to be compiled and executed. This entirely changes my view of web programming. When do I compile? How does the program gets executed (because it will be a machine code, so it must execute as a independent process). How does it communicate with the web server? IPC? and interfacing with all the servers (in my example MATLAB &amp; MySQL) using socket programming? I'm lost!!</p>
</blockquote>

<p>You compile the executable once, the webserver executes the program and passes the data in the request to the program and outputs the received response. CGI specifies that one program instance will be launched per each request. This is why CGI is inefficient and kind of obsolete nowadays.</p>

<blockquote>
  <p>They say that CGI is deprecated. Its no more in use. Is it so? What is its latest update?</p>
</blockquote>

<p>CGI is still used when performance is not paramount and a simple means of executing code is required. It is inefficient for the previously stated reasons and there are more modern means of executing any program in a web enviroment. Currently the most famous is <a href="http://www.fastcgi.com/">FastCGI</a>. </p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089297" title="short permalink to this answer" class="short-link" id="link-post-2089297">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089297/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info user-hover">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089297/revisions" title="show all edits to this post">edited <span title="2013-07-09 06:23:50Z" class="relativetime">Jul 9 '13 at 6:23</span></a>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/246246/animuson"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/FbTIM.jpg" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/246246/animuson">animuson</a><span class="mod-flair" title="moderator">♦</span><br>
        <span class="reputation-score" title="reputation score 24021" dir="ltr">24k</span><span title="17 gold badges"><span class="badge1"></span><span class="badgecount">17</span></span><span title="63 silver badges"><span class="badge2"></span><span class="badgecount">63</span></span><span title="99 bronze badges"><span class="badge3"></span><span class="badgecount">99</span></span>
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:20:13Z" class="relativetime">Jan 18 '10 at 21:20</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/5190/vinko-vrsalovic"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/27a12fdc32baf8748018d373a973d22f" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/5190/vinko-vrsalovic">Vinko Vrsalovic</a><br>
        <span class="reputation-score" title="reputation score 122948" dir="ltr">123k</span><span title="26 gold badges"><span class="badge1"></span><span class="badgecount">26</span></span><span title="244 silver badges"><span class="badge2"></span><span class="badgecount">244</span></span><span title="299 bronze badges"><span class="badge3"></span><span class="badgecount">299</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089297" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="4" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-2021690" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="warm">10</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">More specifically, it describes how request information is passed in environment variables (such as request type, remote IP address), how the reqeust body is passed in via standard input, and how the response is passed out via standard output.  You can refer to the CGI specification (<a href="http://hoohoo.ncsa.illinois.edu/cgi/" rel="nofollow">hoohoo.ncsa.illinois.edu/cgi</a>) for details.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/32082/daf" title="2635 reputation" class="comment-user">daf</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021690_2089297"><span title="2010-01-18 21:23:28Z" class="relativetime-clean">Jan 18 '10 at 21:23</span></a></span>
                    <span class="edited-yes" title="this comment was edited 1 time"></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021698" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">2</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Assuming <code>Server side Program</code> in your figure is my PHP script. So, I never Did any CGI programming? Because I never wrote anything that comes in between webserver &amp; my PHP script. Damn!! this kills me.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/193653/claws" title="9308 reputation" class="comment-user owner">claws</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021698_2089297"><span title="2010-01-18 21:24:52Z" class="relativetime-clean">Jan 18 '10 at 21:24</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021844" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">1</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Michael: But when running via mod_php is not CGI at all (even if based on it). And I agree that CGI refers to both the protocol and the scripts executed via it.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/5190/vinko-vrsalovic" title="122948 reputation" class="comment-user">Vinko Vrsalovic</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021844_2089297"><span title="2010-01-18 21:42:24Z" class="relativetime-clean">Jan 18 '10 at 21:42</span></a></span>
                    <span class="edited-yes" title="this comment was edited 1 time"></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-8726588" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">1</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Hardik: PHP can run using CGI or with a special module (mod_php).</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/5190/vinko-vrsalovic" title="122948 reputation" class="comment-user">Vinko Vrsalovic</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment8726588_2089297"><span title="2011-08-31 07:11:59Z" class="relativetime-clean">Aug 31 '11 at 7:11</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-8729088" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">1</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Vinko Vrsalovic: oh great!!!, than is there any significant performance difference between CGI and mod_php???? like CGI and Servlet Container have. can i compare mod_php and Servlet Container???</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/805437/hardik" title="922 reputation" class="comment-user">hardik</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment8729088_2089297"><span title="2011-08-31 10:06:11Z" class="relativetime-clean">Aug 31 '11 at 10:06</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089297" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link  dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."></a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link " title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick="">show <b>4</b> more comments</a>
            </div>
    </td>
</tr>    </tbody></table>
</div>
<script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk1604852588",4).setZone(44) ; });                    
            </script>
            <div class="everyonelovesstackoverflow" id="adzerk1604852588">
            </div>
  
<a name="2089326"></a>
<div id="answer-2089326" class="answer" data-answerid="2089326" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089326">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">31</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<blockquote>
  <p>What exactly is CGI?</p>
</blockquote>

<p>A means for a web server to get its data from a program (instead of, for instance, a file).</p>

<blockquote>
  <p>Whats the big deal with /cgi-bin/*.cgi? </p>
</blockquote>

<p>No big deal. It is just a convention.</p>

<blockquote>
  <p>I don't know what is this cgi-bin directory on the server for.
  I don't know why they have *.cgi extensions.</p>
</blockquote>

<p>The server has to know what to do with the file (i.e. treat it as a program to execute instead of something to simply serve up). Having a .html extension tells it to use a text/html content type. Having a .cgi extension tells it to run it as a program.</p>

<p>Keeping executables in a separate directory gives some added protection against executing incorrect files and/or serving up CGI programs as raw data in case the server gets misconfigured.</p>

<blockquote>
  <p>Why does Perl always comes in the way. </p>
</blockquote>

<p>It doesn't. Perl was just big and popular at the same time as CGI.</p>

<p>I haven't used Perl CGI for years. I was using mod_perl for a long time, and tend towards PSGI/Plack with FastCGI these days.</p>

<blockquote>
  <p>This book is another great example CGI Programming with Perl
  Why not "CGI Programming with PHP/JSP/ASP". </p>
</blockquote>

<p>CGI isn't very efficient. Better methods for talking to programs from webservers came along at around the same time as PHP. JSP and ASP <em>are</em> different methods for talking to programs.</p>

<blockquote>
  <p>CGI Programming in C this confuses me a lot. in C?? Seriously??</p>
</blockquote>

<p>It is a programming language, why not?</p>

<blockquote>
  <p>When do I compile?</p>
</blockquote>

<ol>
<li>Write code</li>
<li>Compile</li>
<li>Access URL</li>
<li>Webserver runs program</li>
</ol>

<blockquote>
  <p>How does the program gets executed (because it will be a machine code, so it must execute as a independent process).</p>
</blockquote>

<p>It doesn't have to execute as an independent process (you can write Apache modules in C), but the whole concept of CGI is that it launches an external process.</p>

<blockquote>
  <p>How does it communicate with the web server? IPC?</p>
</blockquote>

<p>STDIN/STDOUT and environment variables — as defined in the CGI specification.</p>

<blockquote>
  <p>and interfacing with all the servers (in my example MATLAB &amp; MySQL) using socket 
  programming?</p>
</blockquote>

<p>Using whatever methods you like and are supported.</p>

<blockquote>
  <p>They say that CGI is depreciated. Its no more in use. Is it so? </p>
</blockquote>

<p>CGI is inefficient, slow and simple. It is rarely used, when it is used, it is because it is simple. If performance isn't a big deal, then simplicity is worth a lot.</p>

<blockquote>
  <p>What is its latest update?</p>
</blockquote>

<p>1.1</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089326" title="short permalink to this answer" class="short-link" id="link-post-2089326">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089326/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089326/revisions" title="show all edits to this post">edited <span title="2014-10-01 09:59:18Z" class="relativetime">Oct 1 at 9:59</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <br>
        
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:25:12Z" class="relativetime">Jan 18 '10 at 21:25</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/19068/quentin"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/1d2d3229ed1961d2bd81853242493247" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/19068/quentin">Quentin</a><br>
        <span class="reputation-score" title="reputation score 347482" dir="ltr">347k</span><span title="34 gold badges"><span class="badge1"></span><span class="badgecount">34</span></span><span title="413 silver badges"><span class="badge2"></span><span class="badgecount">413</span></span><span title="575 bronze badges"><span class="badge3"></span><span class="badgecount">575</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089326" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089326" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089505"></a>
<div id="answer-2089505" class="answer" data-answerid="2089505" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089505">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">16</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>CGI is an interface specification between a web server (HTTP server) and an executable program of some type that is to handle a particular request.</p>

<p>It describes how certain properties of that request should be communicated to the environment of that program and how the program should communicate the response back to the server and how the server should 'complete' the response to form a valid reply to the original HTTP request.</p>

<p>For a while CGI was an IETF Internet Draft and as such had an expiry date. It expired with no update so there was no CGI 'standard'. It is now an informational RFC, but as such documents common practice and isn't a standard itself. <a href="http://www.ietf.org/rfc/rfc3875">rfc3875</a></p>

<p>Programs implementing a CGI interface can be written in any language runnable on the target machine. They must be able to access <em>environment variables</em> and usually <em>standard input</em> and they generate their output on <em>standard output</em>.</p>

<p>Compiled languages such as C were commonly used as were scripting languages such as perl, often using libraries to make accessing the CGI environment easier.</p>

<p>One of the big disadvantages of CGI is that a new program is spawned for each request so maintaining state between requests could be a major performance issue. The state might be handled in cookies or encoded in a URL, but if it gets to large it must be stored elsewhere and keyed from encoded url information or a cookie. Each CGI invocation would then have to reload the stored state from a store somewhere.</p>

<p>For this reason, and for a greatly simple interface to requests and sessions, better integrated environments between web servers and applications are much more popular. Environments like a modern php implementation with apache integrate the target language much better with web server and provide access to request and sessions objects that are needed to efficiently serve http requests. They offer a much easier and richer way to write 'programs' to handle HTTP requests.</p>

<p>Whether you wrote a CGI script rather depends on interpretation. It certainly did the job of one but it is much more usual to run php as a module where the interface between the script and the server isn't strictly a CGI interface.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089505" title="short permalink to this answer" class="short-link" id="link-post-2089505">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089505/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089505/revisions" title="show all edits to this post">edited <span title="2010-01-18 22:27:32Z" class="relativetime">Jan 18 '10 at 22:27</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <br>
        
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:53:10Z" class="relativetime">Jan 18 '10 at 21:53</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/19563/charles-bailey"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/a8db27c91db97757a829c7971fd62b84" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/19563/charles-bailey">Charles Bailey</a><br>
        <span class="reputation-score" title="reputation score 260265" dir="ltr">260k</span><span title="40 gold badges"><span class="badge1"></span><span class="badgecount">40</span></span><span title="369 silver badges"><span class="badge2"></span><span class="badgecount">369</span></span><span title="481 bronze badges"><span class="badge3"></span><span class="badgecount">481</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089505" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-2022013" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">1</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Bother. I started writing this when there were no other answers, but got called way. Now it's about #8 in the list. I haven't the will to delete it now, I'll come back and delete it later.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/19563/charles-bailey" title="260265 reputation" class="comment-user">Charles Bailey</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2022013_2089505"><span title="2010-01-18 22:02:03Z" class="relativetime-clean">Jan 18 '10 at 22:02</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2022071" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">2</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Hey.. Please don't delete it. It says some things in more clear way. I found it helpful. May be some others might also find it so.  :)</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/193653/claws" title="9308 reputation" class="comment-user owner">claws</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2022071_2089505"><span title="2010-01-18 22:08:42Z" class="relativetime-clean">Jan 18 '10 at 22:08</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2022092" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">OK, I'll leave it up for a bit. It would probably be good if someone integrated any 'better' passages into one of the fuller answers, though. Then we might have get a more definitive answer.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/19563/charles-bailey" title="260265 reputation" class="comment-user">Charles Bailey</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2022092_2089505"><span title="2010-01-18 22:12:34Z" class="relativetime-clean">Jan 18 '10 at 22:12</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089505" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089341"></a>
<div id="answer-2089341" class="answer" data-answerid="2089341" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089341">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">13</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>The CGI is specified in <a href="http://www.ietf.org/rfc/rfc3875.txt">RFC 3875</a>, though that is a later "official" codification of the original <a href="http://hoohoo.ncsa.uiuc.edu/cgi/">NCSA document</a>. Basically, CGI defines a protocol to pass data about a HTTP request from a webserver to a program to process - any program, in any language. At the time the spec was written (1993), most web servers contained only static pages, "web apps" were a rare and new thing, so it seemed natural to keep them apart from the "normal" static content, such as in a <code>cgi-bin</code> directory apart from the static content, and having them end in <code>.cgi</code>.</p>

<p>At this time, here also were no dedicated "web programming languages" like PHP, and C was the dominating portable programming language - so many people wrote their CGI scripts in C. But Perl quickly turned out to be a better fit for this kind of thing, and CGI became almost synonymous with Perl for a while. Then there came Java Servlets, PHP and a bunch of others and took over large parts of Perl's market share.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089341" title="short permalink to this answer" class="short-link" id="link-post-2089341">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089341/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:27:52Z" class="relativetime">Jan 18 '10 at 21:27</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/16883/michael-borgwardt"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/0382297f273df0a544b0c6c2734de096" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/16883/michael-borgwardt">Michael Borgwardt</a><br>
        <span class="reputation-score" title="reputation score 189947" dir="ltr">190k</span><span title="28 gold badges"><span class="badge1"></span><span class="badgecount">28</span></span><span title="265 silver badges"><span class="badge2"></span><span class="badgecount">265</span></span><span title="508 bronze badges"><span class="badge3"></span><span class="badgecount">508</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089341" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089341" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089335"></a>
<div id="answer-2089335" class="answer" data-answerid="2089335" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089335">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">7</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>CGI is a mechanism whereby an external program is called by the web server in order to handle a request, with environment variables and standard input being used to feed the request data to the program. The exact language the external program is written in does not matter, although it is easier to write CGI programs in some languages versus others.</p>

<p>Since CGI scripts need execute permissions, httpd by default only allows CGI programs in the <code>cgi-bin</code> directory to be run for (possibly now misguided) security purposes.</p>

<p>Most PHP scripts run in the web server process via <code>mod_php</code>. This is not CGI.</p>

<p>CGI is slow since the program (and related interpreter) must be started up per request. Modern alternatives are embedded execution, used by mod_php, and long-running processes, used by FastCGI. A given language may have its own way of implementing those mechanisms, so be sure to ask around before resorting to CGI.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089335" title="short permalink to this answer" class="short-link" id="link-post-2089335">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089335/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:27:17Z" class="relativetime">Jan 18 '10 at 21:27</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/20862/ignacio-vazquez-abrams"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/2343ae368d3241278581ce6c87f62a25" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/20862/ignacio-vazquez-abrams">Ignacio Vazquez-Abrams</a><br>
        <span class="reputation-score" title="reputation score 329140" dir="ltr">329k</span><span title="31 gold badges"><span class="badge1"></span><span class="badgecount">31</span></span><span title="515 silver badges"><span class="badge2"></span><span class="badgecount">515</span></span><span title="708 bronze badges"><span class="badge3"></span><span class="badgecount">708</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089335" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-2021739" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">+1 for someone finally mentioning mod_php!</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/223806/paolo" title="12018 reputation" class="comment-user">Paolo</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021739_2089335"><span title="2010-01-18 21:30:00Z" class="relativetime-clean">Jan 18 '10 at 21:30</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021789" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Hey! I mentioned it below in my answer.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/193619/nathan-osman" title="14554 reputation" class="comment-user">Nathan Osman</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021789_2089335"><span title="2010-01-18 21:35:57Z" class="relativetime-clean">Jan 18 '10 at 21:35</span></a></span>
                    <span class="edited-yes" title="this comment was edited 1 time"></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-8725771" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Ignacio Vazquez-Abrams: if CGI Interface creates a new Process, each time it receives a request for CGI Resource than what is execution difference between CGI and mod_php??????? is CGI and mod_php are the same ???? or is it possible to write PHP scripts that run under CGI Interface not under mod_php???</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/805437/hardik" title="922 reputation" class="comment-user">hardik</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment8725771_2089335"><span title="2011-08-31 05:53:19Z" class="relativetime-clean">Aug 31 '11 at 5:53</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-8740517" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">@Hardik: mod_php runs as part of HTTPd, which is responsible for its own processes.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/20862/ignacio-vazquez-abrams" title="329140 reputation" class="comment-user">Ignacio Vazquez-Abrams</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment8740517_2089335"><span title="2011-08-31 20:36:10Z" class="relativetime-clean">Aug 31 '11 at 20:36</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089335" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2278885"></a>
<div id="answer-2278885" class="answer" data-answerid="2278885" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2278885">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">5</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>You maybe want to know what is not CGI, and the answer is a MODULE for your web server (if I suppose you are runnig Apache). AND THAT'S THE BIG DIFERENCE, because CGI needs and external program, thread, whatever to instantiate a PERL, PHP, C app server where when you run as a MODULE that program is the web server (apache) per-se. </p>

<p>Because of all this there is a lot of performance, security, portability issues that come into play. But it's good to know what is not CGI first, to understand what it is.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2278885" title="short permalink to this answer" class="short-link" id="link-post-2278885">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2278885/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info ">
    <div class="user-action-time">
        answered <span title="2010-02-17 07:06:22Z" class="relativetime">Feb 17 '10 at 7:06</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/90466/denica"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/0b4f2b6666af60b1a2c5fc9fcf1c3bf7" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/90466/denica">denica</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">127</span><span title="1 silver badge"><span class="badge2"></span><span class="badgecount">1</span></span><span title="11 bronze badges"><span class="badge3"></span><span class="badgecount">11</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2278885" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2278885" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089305"></a>
<div id="answer-2089305" class="answer" data-answerid="2089305" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089305">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">5</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>CGI essentially passes the request off to <em>any</em> interpreter that is configured with the web server - This could be Perl, Python, PHP, Ruby, C pretty much anything. Perl was the most common back in the day thats why you often see it in reference to CGI.</p>

<p>CGI is not dead. In fact most large hosting companies run PHP as CGI as opposed to mod_php because it offers user level config and some other things while it is slower than mod_php. Ruby and Python are also typically run as CGI. they key difference here is that a server module runs as part of the actual server software - where as with CGI its totally outside the server The server just uses the CGI module to determine how to pass and recieve data to the outside interpreter.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089305" title="short permalink to this answer" class="short-link" id="link-post-2089305">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089305/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089305/revisions" title="show all edits to this post">edited <span title="2014-07-01 02:22:59Z" class="relativetime">Jul 1 at 2:22</span></a>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/846053/xwlee"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/5c2524c96e647c2235ebb3d96f3cc8fa" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/846053/xwlee">xwlee</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">18</span><span title="6 bronze badges"><span class="badge3"></span><span class="badgecount">6</span></span>
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info ">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:20:52Z" class="relativetime">Jan 18 '10 at 21:20</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/215966/prodigitalson"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/e184311ce0e9f4f18a23ac5cd39797a0" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/215966/prodigitalson">prodigitalson</a><br>
        <span class="reputation-score" title="reputation score 39616" dir="ltr">39.6k</span><span title="2 gold badges"><span class="badge1"></span><span class="badgecount">2</span></span><span title="45 silver badges"><span class="badge2"></span><span class="badgecount">45</span></span><span title="69 bronze badges"><span class="badge3"></span><span class="badgecount">69</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089305" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-2021729" class="comment ">
        <td class="comment-actions">
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                <span title="number of &#39;useful comment&#39; votes received" class="cool">2</span>
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Not downvoting but most python web installs i've seen where on mod_wsgi or mod_python.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/81179/christophed" title="40656 reputation" class="comment-user">ChristopheD</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021729_2089305"><span title="2010-01-18 21:28:30Z" class="relativetime-clean">Jan 18 '10 at 21:28</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-2021753" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Fair enough :-)</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/215966/prodigitalson" title="39616 reputation" class="comment-user">prodigitalson</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#comment2021753_2089305"><span title="2010-01-18 21:32:03Z" class="relativetime-clean">Jan 18 '10 at 21:32</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089305" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089316"></a>
<div id="answer-2089316" class="answer" data-answerid="2089316" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089316">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">4</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>Have a look at <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface" rel="nofollow">CGI</a> in Wikipedia. CGI is a <em>protocol</em> between the web server and a external program or a script that handles the input and generates output that is sent to the browser.</p>

<p>CGI is a simply a way for web server and a program to communicate, nothing more, nothing less. Here the server manages the network connection and HTTP protocol and the program handles input and generates output that is sent to the browser. CGI script can be basically any program that can be executed by the webserver and follows the CGI protocol. Thus a CGI program can be implemented, for example, in  C. However that is extremely rare, since C is not very well suited for the task.</p>

<p><code>/cgi-bin/*.cgi</code> is a simply a path where people commonly put their CGI script. Web server are commonly configured by default to fetch CGI scripts from that path.</p>

<p>a CGI script can be implemented also in PHP, but all PHP programs are not CGI scripts. If webserver has embedded PHP interpreter (e.g. mod_php in Apache), then the CGI phase is skipped by more efficient direct protocol between the web server and the interpreter.</p>

<p>Whether you have implemented a CGI script or not depends on how your script is being executed by the web server.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089316" title="short permalink to this answer" class="short-link" id="link-post-2089316">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089316/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2089316/revisions" title="show all edits to this post">edited <span title="2010-01-18 21:30:14Z" class="relativetime">Jan 18 '10 at 21:30</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <br>
        
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:23:04Z" class="relativetime">Jan 18 '10 at 21:23</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/1431/juha-syrj%c3%a4l%c3%a4"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/69d0034bbc8ef52aeaf67aaa69f37c6d" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/1431/juha-syrj%c3%a4l%c3%a4">Juha Syrjälä</a><br>
        <span class="reputation-score" title="reputation score 12093" dir="ltr">12.1k</span><span title="13 gold badges"><span class="badge1"></span><span class="badgecount">13</span></span><span title="75 silver badges"><span class="badge2"></span><span class="badgecount">75</span></span><span title="131 bronze badges"><span class="badge3"></span><span class="badgecount">131</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089316" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089316" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="2089347"></a>
<div id="answer-2089347" class="answer" data-answerid="2089347" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="2089347">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">2</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>The idea behind CGI is that a program/script (whether Perl or even C) receives input via STDIN (the request data) and outputs data via STDOUT (echo, printf statements). The reason most php scripts don't qualify is because they are run under the PHP Apache module.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2089347" title="short permalink to this answer" class="short-link" id="link-post-2089347">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2089347/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-01-18 21:28:24Z" class="relativetime">Jan 18 '10 at 21:28</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/193619/nathan-osman"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/bba8a1d044a8309d5f9b562ddd3b8bef" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/193619/nathan-osman">Nathan Osman</a><br>
        <span class="reputation-score" title="reputation score 14554" dir="ltr">14.6k</span><span title="23 gold badges"><span class="badge1"></span><span class="badgecount">23</span></span><span title="124 silver badges"><span class="badge2"></span><span class="badgecount">124</span></span><span title="209 bronze badges"><span class="badge3"></span><span class="badgecount">209</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2089347" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-2089347" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="25985255"></a>
<div id="answer-25985255" class="answer" data-answerid="25985255" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="25985255">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">1</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>A CGI is a program (or a Web API) you write, and save it on the Web Server site. CGI is a file.</p>

<p>This file sits and waits on the Web Server.  When the client browser sends a request to the Web Server to execute your CGI file, the Web Server runs your CGI file on the server site. The inputs for this CGI program, if any, are from the client browser. The outputs of this CGI program are sent to the browser.</p>

<p>What language you use to write a CGI program? Other posts already mention c,java, php, perl, etc.</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/25985255" title="short permalink to this answer" class="short-link" id="link-post-25985255">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/25985255/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info ">
    <div class="user-action-time">
        answered <span title="2014-09-23 00:56:07Z" class="relativetime">Sep 23 at 0:56</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/4068598/loc-pham"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/e62c53a4609a00a5ff743547a2562f2a" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/4068598/loc-pham">Loc Pham</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">11</span><span title="1 bronze badge"><span class="badge3"></span><span class="badgecount">1</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-25985255" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-25985255" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>

  
<a name="23199845"></a>
<div id="answer-23199845" class="answer" data-answerid="23199845" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input type="hidden" name="_id_" value="23199845">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">0</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>A real-life example: a complicated database that needs to be shown on a website. Since the database was designed somewhere around 1986 (!), lots of data was packed in different ways to save on disk space. </p>

<p>As the development went on, the developers could no longer solve complicated data requests in SQL alone, for example because the sorting algorythms were unusual. </p>

<p>There are three sensible solutions: </p>

<ol>
<li>quick and dirty: send the unsored data to PHP, sort it there. Obviously a very expensive solution</li>
<li>write a plugin to the database engine (the owner of the server wasn't ready to allow foreign code to run on the server), or </li>
<li>you can pocess the data in a program (C, Perl, etc.), and put it into /cgi-bin.</li>
</ol>

<p>CGI runs your script in Solution #3 and outputs the effect to the browser. You have the speed of the compiled program, the flexibility of a language better than SQL, and no need to write plugins to the SQL server. (Again, this is an example specific to SQL and C)</p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/23199845" title="short permalink to this answer" class="short-link" id="link-post-23199845">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/23199845/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
    <td align="right" class="post-signature">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/23199845/revisions" title="show all edits to this post">edited <span title="2014-10-18 22:35:31Z" class="relativetime">Oct 18 at 22:35</span></a>
    </div>
    <div class="user-gravatar32">
        
    </div>
    <div class="user-details">
        <br>
        
    </div>
</div>    </td>
            


    <td align="right" class="post-signature">   
       

    <div class="user-info ">
    <div class="user-action-time">
        answered <span title="2014-04-21 14:54:53Z" class="relativetime">Apr 21 at 14:54</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/680353/user680353"><div class="gravatar-wrapper-32"><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/96abc30c2ef587ee6ba26d2d8aeacaa7" alt="" width="32" height="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/680353/user680353">user680353</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">187</span><span title="1 silver badge"><span class="badge2"></span><span class="badgecount">1</span></span><span title="8 bronze badges"><span class="badge3"></span><span class="badgecount">8</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-23199845" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>
            <div id="comments-link-23199845" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span><a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" onclick=""></a>
            </div>
    </td>
</tr>    </tbody></table>
</div>
				        <div class="question-status">
        <h2>                    <b>protected</b> by <a href="http://stackoverflow.com/users/2224265/tushar-gupta">Tushar Gupta</a> <span dir="ltr"><span title="2014-10-19 06:54:31Z" class="relativetime">Oct 19 at 6:54</span></span>
</h2>
        <p>
Thank you for your interest in this question.   Because it has attracted low-quality answers, posting an answer now requires 10 <a href="http://stackoverflow.com/help/whats-reputation">reputation</a> on this site.  <br><br>  Would you like to answer one of these <a href="http://stackoverflow.com/unanswered?fromProtectedNotice=true">unanswered questions</a> instead?  </p>
    </div>




						<h2 class="bottom-notice" data-loc="1">
Not the answer you're looking for?							Browse other questions tagged <a href="http://stackoverflow.com/questions/tagged/php" class="post-tag" title="show questions tagged &#39;php&#39;" rel="tag">php</a> <a href="http://stackoverflow.com/questions/tagged/asp.net" class="post-tag" title="show questions tagged &#39;asp.net&#39;" rel="tag">asp.net</a> <a href="http://stackoverflow.com/questions/tagged/jsp" class="post-tag" title="show questions tagged &#39;jsp&#39;" rel="tag">jsp</a> <a href="http://stackoverflow.com/questions/tagged/cgi" class="post-tag" title="show questions tagged &#39;cgi&#39;" rel="tag">cgi</a>  or <a href="http://stackoverflow.com/questions/ask">ask your own question</a>.						</h2>
			</div>
		</div>
				<div id="sidebar" class="show-votes">
						    <div class="module question-stats">
			        <table id="qinfo">
			            <tbody><tr>
			                <td>
			                    <p class="label-key">asked</p>
			                </td>
			                <td style="padding-left: 10px">
			                    <p class="label-key" title="2010-01-18 21:15:48Z"><b>4 years ago</b></p>
			                </td>
			            </tr>
			            <tr>
			                <td>
			                    <p class="label-key">viewed</p>
			                </td>

			                <td style="padding-left: 10px">
			                    <p class="label-key">
			                        <b>58868 times</b>
			                    </p>
			                </td>
			            </tr>
			                <tr>
			                    <td>
			                        <p class="label-key">active</p>
			                    </td>
			                    <td style="padding-left: 10px">
			                        <p class="label-key"><b><a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi?lastactivity" class="lastactivity-link" title="2014-10-18 22:35:31Z">1 month ago</a></b></p>
			                    </td>
			                </tr>
			        </tbody></table>
			    </div>
						
			<script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk677428623",[17,2221]).setZone(45) ; });                    
            </script>
            <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk677428623"><a href="http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6MTcsImJ0IjowLCJjbSI6MTg2NjI0LCJjaCI6MTE3OCwiY3IiOjY1ODAyNCwiZGkiOiIxMzY0NDJlNzU4YTc0NmRjYjA2ZDQyYWRiZjdjNTVmOCIsImRtIjoxLCJmYyI6Njc5NTAwLCJmbCI6NDEwMTgzLCJpcCI6IjExMy4xOTkuMjUzLjEzNyIsImt3IjoicGhwLGFzcC5uZXQsanNwLGNnaSIsIm53IjoyMiwicGMiOjAsInByIjoxNTY4LCJydCI6MSwicmYiOiJodHRwczovL3d3dy5nb29nbGUuY29tLm5wLyIsInN0Ijo4Mjc3LCJ1ayI6InVlMS1hNzQ1OTY1ZWQ3Yzk0ZTczYjQ3NDliNTE5YTdmYjBiNyIsInpuIjo0NSwidHMiOjE0MTYzODA4OTcwMjMsImJmIjp0cnVlLCJ1ciI6Imh0dHA6Ly9jYXJlZXJzLnN0YWNrb3ZlcmZsb3cuY29tL2pvYnMvcmVtb3RlP3V0bV9zb3VyY2U9c3RhY2tvdmVyZmxvdy5jb20mdXRtX21lZGl1bT1hZCZ1dG1fY2FtcGFpZ249Y2FuZGlkYXRlcy13ZmgmdXRtX2NvbnRlbnQ9c2Itd2ZoLWNhdCJ9&s=RSDfHF-nly-82BkJXlcSYUMEgug" rel="nofollow" target="_blank" title=""><img src="./php - I never really understood  what is CGI  - Stack Overflow_files/c050fce5e0094decb57fdb53f4ca4254.jpg" title="" alt="" border="0" width="220" height="250"></a><img height="0px" width="0px" border="0" style="position:absolute;" src="./php - I never really understood  what is CGI  - Stack Overflow_files/i(1).gif"><div class="adzerk-vote-controls" style="display: none;"><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li><label><input type="radio" value="12" name="downvoteReason">Uninteresting</label></li><li><label><input type="radio" value="13" name="downvoteReason">Misleading</label></li><li><label><input type="radio" value="14" name="downvoteReason">Offensive</label></li><li><label><input type="radio" value="15" name="downvoteReason">Repetitive</label></li></ul><a href="http://stackoverflow.com/questions/2089271/i-never-really-understood-what-is-cgi#" class="adzerk-vote-cancel">Oops! I didn't mean to do this.</a></form></div></div>  
        <div id="hireme" class=" blue tagged">  <a href="http://careers.stackoverflow.com/?a=6nYqs&utm_source=stackoverflow.com&utm_medium=ad&utm_campaign=jobs-small-job-tags-weighted-control" class="top" target="_blank"> </a> <ul class="jobs"> <li> <a href="http://careers.stackoverflow.com/jobs/71428/developer-aspnet-mvc-webapi-tdd-agile-totaljobs-group?a=nXc5hVrlMrf&utm_source=stackoverflow.com&utm_medium=ad&utm_campaign=jobs-small-job-tags-weighted-control" target="_blank" title="Developer - ASP.Net / MVC / WebAPI / TDD / Agile at Totaljobs Group. Click to learn more."> <span class="title">Developer - ASP.Net / MVC / WebAPI / TDD / Agile</span> <span class="company">Totaljobs Group</span> <span class="location">London, UK</span> <span class="post-tag">asp.net-mvc</span> <span class="post-tag">tdd</span> </a> </li> <li> <a href="http://careers.stackoverflow.com/jobs/70444/software-quality-assurance-engineer-american-express?a=nCJyjvLBP2i&utm_source=stackoverflow.com&utm_medium=ad&utm_campaign=jobs-small-job-tags-weighted-control" target="_blank" title="Software Quality Assurance Engineer at American Express. Click to learn more."> <span class="title">Software Quality Assurance Engineer</span> <span class="company">American Express</span> <span class="location">Phoenix, AZ</span> <span class="post-tag">testing</span> <span class="post-tag">java</span> </a> </li> </ul> <img alt="" class="impression" src="./php - I never really understood  what is CGI  - Stack Overflow_files/nXc5hVrlMrf-nCJyjvLBP2i-6nYqs" style="display:none"> </div>
			<div style="margin-bottom: 10px;">
        

<style type="text/css">
#newsletter-ad {
    width: 190px;
    height: 250px;
    overflow: hidden;
    background: url('//cdn.sstatic.net/stackoverflow/img/newsletter-ad.png');
    padding: 0 15px 0 15px;
}
#newsletter-ad-header {
    margin-top: 60px;
}
#newsletter-ad ul {
    margin: 1em 0 1em 1.5em;
}
#newsletter-ad ul li {
    margin-bottom: 5px;
}
#newsletter-signup-container {
    text-align: center;
}
#newsletter-preview-container {
    margin-top: 10px;
    text-align: center;
}
#newsletter-email-input {
    width: 200px;
}
</style>

<script>
    StackExchange.ready(function () {
        StackExchange.newsletterAd.init();
    });
</script>

<div id="newsletter-ad">
    <p id="newsletter-ad-header">Get the <b>weekly newsletter!</b></p>
    <ul>
        <li>Top questions and answers</li>
        <li>Important announcements</li>
        <li>Unanswered questions</li>
    </ul>
    <div id="newsletter-signup-container"><input id="newsletter-signup" type="button" value="Sign up for the newsletter"></div>
    <p id="newsletter-preview-container">see an <a href="http://stackexchange.com/newsletters/newsletter?site=stackoverflow.com" id="newsletter-preview">example newsletter</a></p>
    <div class="dno">
        
<p class="privacy-policy-agreement">
By subscribing, you agree to the <a href="http://stackexchange.com/legal/privacy-policy" target="_blank">privacy policy</a> and <a href="http://stackexchange.com/legal/terms-of-service" target="_blank">terms of service</a>.</p>
<input type="hidden" name="legalLinksShown" value="1">
    </div>
</div>

    </div>  
    
            <div class="module sidebar-linked">
	<h4 id="h-linked">Linked</h4>
	<div class="linked" data-tracker="lq=1">
<div class="spacer">
	<a href="http://stackoverflow.com/q/14062201?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes answered-accepted default">6</div>
	</a>
	<a href="http://stackoverflow.com/questions/14062201/how-does-php-interact-with-http-servers-like-lighttpd?lq=1" class="question-hyperlink">How does PHP interact with HTTP servers? (like lighttpd)</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/16600950?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes  default">-6</div>
	</a>
	<a href="http://stackoverflow.com/questions/16600950/what-is-a-cgi-in-perl?lq=1" class="question-hyperlink">What is a CGI in Perl</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/7056697?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes answered-accepted default">4</div>
	</a>
	<a href="http://stackoverflow.com/questions/7056697/how-does-a-webserver-interface-with-php?lq=1" class="question-hyperlink">How does a webserver interface with PHP</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/3841889?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes  default">1</div>
	</a>
	<a href="http://stackoverflow.com/questions/3841889/in-what-situation-can-cgi-be-faster-than-servlet?lq=1" class="question-hyperlink">In what situation can CGI be faster than Servlet?</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/14169325?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes answered-accepted default">0</div>
	</a>
	<a href="http://stackoverflow.com/questions/14169325/a-router-like-web-interface-for-a-sbc-ts-7500?lq=1" class="question-hyperlink">A Router like Web Interface for a SBC (TS-7500)</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/26238546?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes  default">-4</div>
	</a>
	<a href="http://stackoverflow.com/questions/26238546/what-language-should-i-use-for-creating-a-web-page-that-would-allow-me-to-run-ba?lq=1" class="question-hyperlink">What language should I use for creating a web page that would allow me to run bash script in it?</a>
</div><div class="spacer">
	<a href="http://stackoverflow.com/q/26063803?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes  default">0</div>
	</a>
	<a href="http://stackoverflow.com/questions/26063803/web-interface-to-control-functions-in-os?lq=1" class="question-hyperlink">Web Interface to Control Functions in OS</a>
</div>			</div>
</div>

				<div class="module sidebar-related">
					<h4 id="h-related">Related</h4>
                    <div class="related js-gps-related-questions" data-tracker="rq=1">
                        <div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/139760?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">1
    </div>
</a><a href="http://stackoverflow.com/questions/139760/are-there-alternatives-to-cgi-and-do-i-really-need-one?rq=1" class="question-hyperlink">Are there alternatives to CGI (and do I really need one)?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/219110?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">94
    </div>
</a><a href="http://stackoverflow.com/questions/219110/how-python-web-frameworks-wsgi-and-cgi-fit-together?rq=1" class="question-hyperlink">How Python web frameworks, WSGI and CGI fit together</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/1539490?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">0
    </div>
</a><a href="http://stackoverflow.com/questions/1539490/is-request-forwarding-possible-when-using-cgi?rq=1" class="question-hyperlink">Is request forwarding possible when using CGI?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/2368113?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">2
    </div>
</a><a href="http://stackoverflow.com/questions/2368113/problems-with-cgi-wrapper-for-php?rq=1" class="question-hyperlink">Problems with CGI wrapper for PHP</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/5214268?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">2
    </div>
</a><a href="http://stackoverflow.com/questions/5214268/cgi-is-inefficient-but-what-is-being-used-that-is-so-different-nowaydays?rq=1" class="question-hyperlink">CGI is inefficient, but what is being used that is so different nowaydays?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/6899467?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">0
    </div>
</a><a href="http://stackoverflow.com/questions/6899467/how-does-the-apache-httpd-webserver-communicate-with-perl-or-php-or-cgi-and-gets?rq=1" class="question-hyperlink">How does the Apache httpd webserver communicate with Perl or PHP or CGI and gets the output and returns the response?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/10507979?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">2
    </div>
</a><a href="http://stackoverflow.com/questions/10507979/cant-include-execute-a-cgi-file-inside-a-php-file?rq=1" class="question-hyperlink">Can't include/execute a CGI file inside a PHP file</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/11498031?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">2
    </div>
</a><a href="http://stackoverflow.com/questions/11498031/how-to-call-php-cgi-from-c?rq=1" class="question-hyperlink">How to call php-cgi from c++</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/13322741?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">4
    </div>
</a><a href="http://stackoverflow.com/questions/13322741/c-cgi-nowadays?rq=1" class="question-hyperlink">C++ CGI nowadays</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/22822490?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">0
    </div>
</a><a href="http://stackoverflow.com/questions/22822490/my-understanding-of-cgi?rq=1" class="question-hyperlink">My understanding of CGI</a>
</div>

                    </div>
				</div>
            
<div id="hot-network-questions" class="module">
    <h4>
        <a href="http://stackexchange.com/questions?tab=hot" class="js-gps-track" data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">
            Hot Network Questions
        </a>
    </h4>
    <ul>
            <li>
                <div class="favicon favicon-superuser" title="Super User"></div><a href="http://superuser.com/questions/841653/putty-or-other-keep-executing-command-even-after-exiting-putty" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:3 }); posts_hot_network.click({ item_type:2, location:11 })">
                    PuTTY or OTHER - Keep executing command even after exiting PuTTY
                </a>

            </li>
            <li>
                <div class="favicon favicon-apple" title="Ask Different"></div><a href="http://apple.stackexchange.com/questions/157120/can-i-re-download-the-default-keyboard-ios-8-after-deleting-it" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:118 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Can I re-download the default keyboard (iOS 8) after deleting it?
                </a>

            </li>
            <li>
                <div class="favicon favicon-english" title="English Language &amp; Usage Stack Exchange"></div><a href="http://english.stackexchange.com/questions/208866/how-can-i-describe-a-low-temperature-that-doesnt-actually-feel-cold" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:97 }); posts_hot_network.click({ item_type:2, location:11 })">
                    how can I describe a low temperature that doesn't actually feel cold?
                </a>

            </li>
            <li>
                <div class="favicon favicon-photo" title="Photography Stack Exchange"></div><a href="http://photo.stackexchange.com/questions/56820/how-to-judge-the-difference-between-the-real-photo-and-what-you-see-in-lcd" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:61 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How to judge the difference between the real photo and what you see in LCD?
                </a>

            </li>
            <li>
                <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/4934/thief-among-the-four" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Thief Among the Four
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-judaism" title="Mi Yodeya"></div><a href="http://judaism.stackexchange.com/questions/48478/why-do-beit-shammai-and-beit-hillel-always-argue" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:248 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why do Beit Shammai and Beit Hillel always argue?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-english" title="English Language &amp; Usage Stack Exchange"></div><a href="http://english.stackexchange.com/questions/208756/what-is-a-word-that-means-unforgettable-but-with-a-negative-connotation" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:97 }); posts_hot_network.click({ item_type:2, location:11 })">
                    What is a word that means unforgettable but with a negative connotation?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/5100/mosaic-with-tetris-blocks" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Mosaic with tetris blocks
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-space" title="Space Exploration Stack Exchange"></div><a href="http://space.stackexchange.com/questions/6007/would-a-moon-resident-age-differently-than-someone-living-on-earth" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:508 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Would a Moon resident age differently than someone living on Earth?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-aviation" title="Aviation Stack Exchange"></div><a href="http://aviation.stackexchange.com/questions/9764/what-happens-when-a-pilot-has-no-instrument-rating-and-visibility-drops" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:528 }); posts_hot_network.click({ item_type:2, location:11 })">
                    What happens when a pilot has no Instrument Rating and visibility drops?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-graphicdesign" title="Graphic Design Stack Exchange"></div><a href="http://graphicdesign.stackexchange.com/questions/42306/why-do-two-perfectly-adjacent-rectangles-create-black-or-white-lines-in-between" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:174 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why do two perfectly adjacent rectangles create black or white lines in between as if they were overlapping or not exactly adjacent?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1028077/9th-grade-math-problem-appears-to-be-unsolvable" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">
                    9th grade math problem appears to be unsolvable?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-mathoverflow" title="MathOverflow"></div><a href="http://mathoverflow.net/questions/187494/is-there-any-relationship-between-the-topologies-of-the-clique-complex-and-the-i" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:504 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is there any relationship between the topologies of the clique complex and the independence complex?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-physics" title="Physics Stack Exchange"></div><a href="http://physics.stackexchange.com/questions/147553/does-the-heat-equation-violate-causality" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:151 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Does the heat equation violate causality?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="http://security.stackexchange.com/questions/73072/should-i-use-base64-or-unicode-for-storing-hashes-salts" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:162 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Should I Use Base64 or Unicode for Storing Hashes &amp; Salts?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1028096/problem-with-infinitely-many-converging-subsequences" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Problem with infinitely many converging subsequences
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-aviation" title="Aviation Stack Exchange"></div><a href="http://aviation.stackexchange.com/questions/9779/launching-aircraft-carried-aircraft" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:528 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Launching aircraft-carried aircraft
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-politics" title="Politics Stack Exchange"></div><a href="http://politics.stackexchange.com/questions/6318/why-does-in-the-u-s-the-left-wing-party-hates-being-called-socialist-but-in" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:475 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why does in the U.S. the left-wing party hates being called "socialist", but in France the left-wing party proudly calls itself "the Socialist Party"?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-academia" title="Academia Stack Exchange"></div><a href="http://academia.stackexchange.com/questions/31900/how-do-advisors-typically-apply-pressure-on-phd-students-to-get-work-done" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:415 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How do advisors typically apply pressure on PhD students to get work done?
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-workplace" title="The Workplace Stack Exchange"></div><a href="http://workplace.stackexchange.com/questions/36368/a-co-worker-is-using-my-cup" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:423 }); posts_hot_network.click({ item_type:2, location:11 })">
                    A co-worker is using my cup
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1028524/is-this-series-convergent-or-divergent-with-factorials-alternating-series" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is this series convergent or divergent? (with factorials/alternating series)
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-unix" title="Unix &amp; Linux Stack Exchange"></div><a href="http://unix.stackexchange.com/questions/168710/formatting-the-output-of-grep-when-matching-on-multiple-files" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:106 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Formatting the output of grep when matching on multiple files
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/5090/generating-ice-sliding-puzzles-which-spell-out-words" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Generating ice-sliding puzzles which spell out words
                </a>

            </li>
            <li class="dno js-hidden" style="display: list-item;">
                <div class="favicon favicon-scifi" title="Science Fiction &amp; Fantasy Stack Exchange"></div><a href="http://scifi.stackexchange.com/questions/73019/where-is-this-character-going-at-the-end-of-interstellar" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Where is this character going at the end of Interstellar?
                </a>

            </li>
    </ul>

        
</div>
		</div>
	
<div id="feed-link">
    <div id="feed-link-text">
        <a href="http://stackoverflow.com/feeds/question/2089271" title="feed of this question and its answers">
            <span class="feed-icon"></span>question feed
        </a>
    </div>
</div>	<script>
StackExchange.ready(function(){$.get('/posts/2089271/ivc/82c9');});
</script>
<noscript>
    &lt;div&gt;&lt;img src="/posts/2089271/ivc/82c9" class="dno" alt="" width="0" height="0"&gt;&lt;/div&gt;
</noscript><div style="display:none" id="prettify-lang">lang-php</div></div>



        </div>
    </div>
    <div id="footer" class="categories">
        <div class="footerwrap">
            <div id="footer-menu">
                <div class="top-footer-links">
                        <a href="http://stackoverflow.com/tour">tour</a>
                    <a href="http://stackoverflow.com/help">help</a>
                    <a href="http://blog.stackoverflow.com/?blb=1">blog</a>
                        <a href="http://chat.stackoverflow.com/">chat</a>
                    <a href="http://data.stackexchange.com/">data</a>
                    <a href="http://stackexchange.com/legal">legal</a>
                    <a href="http://stackexchange.com/legal/privacy-policy">privacy policy</a>
                    <a href="http://stackexchange.com/work-here">work here</a>
                    <a href="http://stackexchange.com/mediakit">advertising info</a>

                    <a onclick="StackExchange.switchMobile(&quot;on&quot;)">mobile</a>
                    <b><a href="http://stackoverflow.com/contact">contact us</a></b>
                        <b><a href="http://meta.stackoverflow.com/">feedback</a></b>
                    
                </div>
                <div id="footer-sites">
                    <table>
    <tbody><tr>
            <th colspan="3">
                Technology
            </th>
            <th>
                Life / Arts
            </th>
            <th>
                Culture / Recreation
            </th>
            <th>
                Science
            </th>
            <th>
                Other
            </th>
    </tr>
    <tr>
            <td>
                <ol>
                        <li><a href="http://stackoverflow.com/" title="professional and enthusiast programmers">Stack Overflow</a></li>
                        <li><a href="http://serverfault.com/" title="professional system and network administrators">Server Fault</a></li>
                        <li><a href="http://superuser.com/" title="computer enthusiasts and power users">Super User</a></li>
                        <li><a href="http://webapps.stackexchange.com/" title="power users of web applications">Web Applications</a></li>
                        <li><a href="http://askubuntu.com/" title="Ubuntu users and developers">Ask Ubuntu</a></li>
                        <li><a href="http://webmasters.stackexchange.com/" title="pro webmasters">Webmasters</a></li>
                        <li><a href="http://gamedev.stackexchange.com/" title="professional and independent game developers">Game Development</a></li>
                        <li><a href="http://tex.stackexchange.com/" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://programmers.stackexchange.com/" title="professional programmers interested in conceptual questions about software development">Programmers</a></li>
                        <li><a href="http://unix.stackexchange.com/" title="users of Linux, FreeBSD and other Un*x-like operating systems.">Unix &amp; Linux</a></li>
                        <li><a href="http://apple.stackexchange.com/" title="power users of Apple hardware and software">Ask Different (Apple)</a></li>
                        <li><a href="http://wordpress.stackexchange.com/" title="WordPress developers and administrators">WordPress Development</a></li>
                        <li><a href="http://gis.stackexchange.com/" title="cartographers, geographers and GIS professionals">Geographic Information Systems</a></li>
                        <li><a href="http://electronics.stackexchange.com/" title="electronics and electrical engineering professionals, students, and enthusiasts">Electrical Engineering</a></li>
                        <li><a href="http://android.stackexchange.com/" title="enthusiasts and power users of the Android operating system">Android Enthusiasts</a></li>
                        <li><a href="http://security.stackexchange.com/" title="Information security professionals">Information Security</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://dba.stackexchange.com/" title="database professionals who wish to improve their database skills and learn from others in the community">Database Administrators</a></li>
                        <li><a href="http://drupal.stackexchange.com/" title="Drupal developers and administrators">Drupal Answers</a></li>
                        <li><a href="http://sharepoint.stackexchange.com/" title="SharePoint enthusiasts">SharePoint</a></li>
                        <li><a href="http://ux.stackexchange.com/" title="user experience researchers and experts">User Experience</a></li>
                        <li><a href="http://mathematica.stackexchange.com/" title="users of Mathematica">Mathematica</a></li>
                        <li><a href="http://salesforce.stackexchange.com/" title="Salesforce administrators, implementation experts, developers and anybody in-between">Salesforce</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#technology" class="more">
                                more (13)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://photo.stackexchange.com/" title="professional, enthusiast and amateur photographers">Photography</a></li>
                        <li><a href="http://scifi.stackexchange.com/" title="science fiction and fantasy enthusiasts">Science Fiction &amp; Fantasy</a></li>
                        <li><a href="http://graphicdesign.stackexchange.com/" title="Graphic Design professionals, students, and enthusiasts">Graphic Design</a></li>
                        <li><a href="http://cooking.stackexchange.com/" title="professional and amateur chefs">Seasoned Advice (cooking)</a></li>
                        <li><a href="http://diy.stackexchange.com/" title="contractors and serious DIYers">Home Improvement</a></li>
                        <li><a href="http://money.stackexchange.com/" title="people who want to be financially literate">Personal Finance &amp; Money</a></li>
                        <li><a href="http://academia.stackexchange.com/" title="academics and those enrolled in higher education">Academia</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#lifearts" class="more">
                                more (10)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://english.stackexchange.com/" title="linguists, etymologists, and serious English language enthusiasts">English Language &amp; Usage</a></li>
                        <li><a href="http://skeptics.stackexchange.com/" title="scientific skepticism">Skeptics</a></li>
                        <li><a href="http://judaism.stackexchange.com/" title="those who base their lives on Jewish law and tradition and anyone interested in learning more">Mi Yodeya (Judaism)</a></li>
                        <li><a href="http://travel.stackexchange.com/" title="road warriors and seasoned travelers">Travel</a></li>
                        <li><a href="http://christianity.stackexchange.com/" title="committed Christians, experts in Christianity and those interested in learning more">Christianity</a></li>
                        <li><a href="http://gaming.stackexchange.com/" title="passionate videogamers on all platforms">Arqade (gaming)</a></li>
                        <li><a href="http://bicycles.stackexchange.com/" title="people who build and repair bicycles, people who train cycling, or commute on bicycles">Bicycles</a></li>
                        <li><a href="http://rpg.stackexchange.com/" title="gamemasters and players of tabletop, paper-and-pencil role-playing games">Role-playing Games</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#culturerecreation" class="more">
                                more (21)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://math.stackexchange.com/" title="people studying math at any level and professionals in related fields">Mathematics</a></li>
                        <li><a href="http://stats.stackexchange.com/" title="people interested in statistics, machine learning, data analysis, data mining, and data visualization">Cross Validated (stats)</a></li>
                        <li><a href="http://cstheory.stackexchange.com/" title="theoretical computer scientists and researchers in related fields">Theoretical Computer Science</a></li>
                        <li><a href="http://physics.stackexchange.com/" title="active researchers, academics and students of physics">Physics</a></li>
                        <li><a href="http://mathoverflow.net/" title="professional mathematicians">MathOverflow</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#science" class="more">
                                more (7)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://stackapps.com/" title="apps, scripts, and development with the Stack Exchange API">Stack Apps</a></li>
                        <li><a href="http://meta.stackexchange.com/" title="meta-discussion of the Stack Exchange family of Q&amp;A websites">Meta Stack Exchange</a></li>
                        <li><a href="http://area51.stackexchange.com/" title="proposing new sites in the Stack Exchange network">Area 51</a></li>
                        <li><a href="http://careers.stackoverflow.com/?utm_source=stackoverflow.com&utm_medium=site-ui&utm_campaign=footerlink">Stack Overflow Careers</a></li>
                    
                </ol>
            </td>
    </tr>
</tbody></table>
                </div>
            </div>

            <div id="copyright">
                site design / logo © 2014 stack exchange inc; user contributions licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license">cc by-sa 3.0</a>                   with <a href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license">attribution required</a>
            </div>
            <div id="svnrev">
                rev 2014.11.18.2025
            </div>
            
        </div>
    <iframe id="global-auth-frame" style="display:none" src="./php - I never really understood  what is CGI  - Stack Overflow_files/read.html"></iframe></div>
    <noscript>
        &lt;div id="noscript-warning"&gt;Stack Overflow works best with JavaScript enabled&lt;img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"&gt;&lt;/div&gt;
    </noscript>
<script>var p = "http", d = "static"; if (document.location.protocol == "https:") { p += "s"; d = "engine"; } var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = p + "://" + d + ".adzerk.net/ados.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script>
<script>
    var ados = ados || {};
    ados.run = ados.run || [];
    ados.run.push(function () { ados_setKeywords('php,asp.net,jsp,cgi');; ados_load(); });         
</script>

    <script>
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
        ga('create', 'UA-5620270-1');        
        
        ga('set', 'dimension2', '|php|asp.net|jsp|cgi|');         
        ga('send', 'pageview');
        var _qevents = _qevents || [],
            _comscore = _comscore || [];
        (function () {
            var ssl='https:'==document.location.protocol,
                s=document.getElementsByTagName('script')[0],
                qc=document.createElement('script');
            qc.async=true;
            qc.src=(ssl?'https://secure':'http://edge')+'.quantserve.com/quant.js';
            s.parentNode.insertBefore(qc, s);
            var sc=document.createElement('script');
            sc.async=true;
            sc.src=(ssl?'https://sb':'http://b') + '.scorecardresearch.com/beacon.js';
            s.parentNode.insertBefore(sc, s);
        })();
        _comscore.push({ c1: "2", c2: "17440561" });
        _qevents.push({ qacct: "p-c1rF4kxgLUzNc" });
    </script>        
    
    
</body></html>